package com.snailhd.framework.common.entity;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;

/**
 * @author hd
 * @date 2020-08-28 00:18
 */

@Setter
@Getter
@NoArgsConstructor
public class PageData<T> implements Serializable {

    private Long pages;

    private Long total;

    private List<T> list;

    public boolean isNotEmpty(){
        return list!=null && !list.isEmpty();
    }

    public PageData<T> gen(PageData pageData,List<T> list){
        setPages(pageData.getPages());
        setTotal(pageData.getTotal());
        setList(list);
        return this;
    }

    public PageData(List<T> list) {
        this.list = list;
    }

    public PageData(Long total, List<T> list) {
        this.total = total;
        this.list = list;
    }

    public PageData(Long pages, Long total, List<T> list) {
        this.pages = pages;
        this.total = total;
        this.list = list;
    }
}
